package io.framework.modules.hpinfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.framework.common.service.impl.CrudServiceImpl;
import io.framework.common.utils.ConvertUtils;
import io.framework.modules.hpinfo.dao.VTHpglSpfjinfoDao;
import io.framework.modules.hpinfo.dto.VTHpglSpfjinfoDTO;
import io.framework.modules.hpinfo.entity.VTHpglSpfjinfoEntity;
import io.framework.modules.hpinfo.service.VTHpglSpfjinfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 环境影响评价管理-环评附件信息
 *
 * @author Gujq email
 * @since 1.0.0 2020-04-13
 */
@Service
public class VTHpglSpfjinfoServiceImpl extends CrudServiceImpl<VTHpglSpfjinfoDao, VTHpglSpfjinfoEntity, VTHpglSpfjinfoDTO> implements VTHpglSpfjinfoService {

    @Autowired
    private VTHpglSpfjinfoDao vtHpglSpfjinfoDao;

    @Override
    public QueryWrapper<VTHpglSpfjinfoEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<VTHpglSpfjinfoEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public List<VTHpglSpfjinfoDTO> getSpfjInfoByProjectId(String id){

        List<VTHpglSpfjinfoEntity> entities =  vtHpglSpfjinfoDao.getSpfjInfoByProjectId(id);

        return ConvertUtils.sourceToTarget(entities,VTHpglSpfjinfoDTO.class);
    }

}